package com.lx.service.impl;

import com.lx.dto.SecurityUser;
import com.lx.entity.User;
import com.lx.service.UserService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.ReactiveUserDetailsService;
import org.springframework.security.core.userdetails.UserDetails;

import reactor.core.publisher.Mono;

/**
 * 实现登录
 *
 * @author 段誉
 * @create 2019-05-21 9:34
 */
public class WebReactiveUserDetailsServiceImpl implements ReactiveUserDetailsService {
  @Autowired
  private UserService userService;
  /**
   * 实现登录
   * @param username 用户名
   * @return
   */
  @Override
  public Mono<UserDetails> findByUsername(String username) {
    System.out.println("---------------" + username);
    User user = userService.getUserInfoByUsername(username);
    return Mono.just(new SecurityUser(user));
  }
}
